<template>
  <div class="search">
    <f-form ref="form" :action="api.highspeedtrain" :form-key="this.formItem.highSpeedTrainId" >
      <f-form-item label="高铁名称"  name="highSpeedTrainName" dataType="${formField.dataType}"   :value="formItem.highSpeedTrainName" />
      <f-form-item label="高铁地址"  name="highSpeedTrainAddress" dataType="${formField.dataType}"   :value="formItem.highSpeedTrainAddress" />
      <f-form-item label="高铁电话"  name="highSpeedTrainPhone" dataType="${formField.dataType}"   :value="formItem.highSpeedTrainPhone" />
      <f-form-item label="高铁排序"  name="highSpeedTrainSort" dataType="number"   :value="formItem.highSpeedTrainSort" />
      <f-form-item label="高铁首字母"  name="letter" dataType="${formField.dataType}"   :value="formItem.letter" />
      <f-form-item label="百度城市编号"  name="cityCode" dataType="${formField.dataType}"   :value="formItem.cityCode" />
      <f-form-item label="区号"  name="areaCode" dataType="${formField.dataType}"   :value="formItem.areaCode" />
      <f-form-item label="创建日期"  name="createDate" dataType="${formField.dataType}"   :value="formItem.createDate" />
    </f-form>
  </div>
</template>
<script>
  import api from './js/api'
  export default {
    name: 'highspeedtrainForm',
    props: {},
    data() {
      return {
        refs:this.$refs,
        api:  Object.assign(api, this.api),
        isAdd: true,//是否是添加模式
        loaded: false,//是否加载完成
        formItem: this.getFormItem()
      }
    },
    methods: {
      getFormItem() {
        return {
          highSpeedTrainId: '',
          highSpeedTrainName: '',
          highSpeedTrainAddress: '',
          highSpeedTrainPhone: '',
          highSpeedTrainSort: '',
          letter: '',
          cityCode: '',
          areaCode: '',
          createDate: ''
        }
      },
      //表单赋值
      setData(data) {
        this.$refs.form.resetFields()
        this.formItem = this.getFormItem()
        if (data && data.highSpeedTrainId) {
          let params={
              highSpeedTrainId:data.highSpeedTrainId
          }
          this.refs['form'].getDetails(params,(data)=>{
             this.formItem=data
             this.loaded = true
          })
          this.isAdd = false
        } else {
          this.loaded = true
        }
      },
      //提交表单
      handleSubmit(callback) {
        this.$refs.form.submit({  }, callback)
      }
    },
    created() {
    },
    components: {}
  }
</script>

<style scoped lang="less" rel="stylesheet/less">

</style>
